package com.springcloud.ribbondemo.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.client.loadbalancer.LoadBalanced
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.client.RestTemplate

@RestController
class MyController {

    @Autowired
    RestTemplate rest

    /*
    p1使用响应时间加权负载均衡
     */
    @GetMapping('/p1')
    String p1()
    {
        rest.getForObject('http://p1/get',String.class)
    }

    /*
    p2使用随机负载均衡
     */
    @GetMapping('/p2')
    String p2()
    {
        rest.getForObject('http://p2/get',String.class)
    }

}
